using System;
using Firestarter.Test.Base;
using FireStarterModeller.BO;
using FireStarterModeller.UI.Wizards;
using Habanero.BO;
using Habanero.Faces.Base;
using Habanero.Faces.Win;
using NUnit.Framework;
using Rhino.Mocks;

namespace FireStarterModeller.Test.UI.Wizards
{
    [TestFixture]
    public class TestDeleteDMPropWizardController
    {
        [SetUp]
        public void SetupTest()
        {
            //Runs every time that any testmethod is executed
            TestUtilsDomain.SetupTest();
            GlobalUIRegistry.ControlFactory = new ControlFactoryWin();
        }

        [TestFixtureSetUp]
        public void TestFixtureSetup()
        {
            //Code that is executed before any test is run in this class. If multiple tests
            // are executed then it will still only be called once.
            TestUtilsDomain.SetupFixture();
        }

        [TearDown]
        public void TearDownTest()
        {
            //runs every time any testmethod is complete
        }


        [Test]
        public void Test_CreateController_WhenDMProperty()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            var cntrller = new DeleteDMPropertyWizardController(dmProp);
            //---------------Test Result -----------------------
            Assert.AreSame(dmProp, cntrller.DMProperty);
        }
        [Test]
        public void Test_Construct_WithNullDMProperty_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProp = null;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                new DeleteDMPropertyWizardController(dmProp);
                Assert.Fail("expected ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("Value cannot be null", ex.Message);
                StringAssert.Contains("dmProp", ex.ParamName);
            }
        }


        private DeleteDMPropertyWizardController GetDeleteDMPropertyWizardController(DMProperty dmProp)
        {
            return new DeleteDMPropertyWizardController(dmProp);
        }

/*

        [Test]
        public void TestWizardControllerSetup_ShouldSetupStep1And2()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProp = MockRepository.GenerateMock<DMProperty>(ConstructForFakes.True);
            SetHasRelationshipWithFK(dmProp, true);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            IWizardControl wzrdControl = GlobalUIRegistry.ControlFactory.CreateWizardControl(cntrller);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            wzrdControl.Start();
            //---------------Test Result -----------------------
            Assert.AreEqual(3, cntrller.StepCount);
            Assert.IsInstanceOf(typeof(DeleteDMPropertyWizardStep1), cntrller.GetFirstStep());
            Assert.IsTrue(cntrller.IsFirstStep());
            Assert.IsFalse(cntrller.IsLastStep());
            var secondStep = cntrller.GetNextStep();
            Assert.IsInstanceOf(typeof(DeleteDMPropertyWizardStep2), secondStep);
            var thirdStep = cntrller.GetNextStep();
            Assert.IsInstanceOf(typeof(DeleteDMPropertyWizardStep3), thirdStep);
        }

        [Test]
        public void Test_Construct_WhenHasRelationshipsWithFK_False_ShouldHaveOneStep()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProp = MockRepository.GenerateMock<DMProperty>(ConstructForFakes.True);
            SetHasRelationshipWithFK(dmProp, false);
            //---------------Assert Precondition----------------
            Assert.IsFalse(dmProp.HasRelationshipsWithRelatedFK);
            //---------------Execute Test ----------------------
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Test Result -----------------------
            Assert.AreEqual(1, cntrller.StepCount);
        }
        [Test]
        public void Test_Construct_WhenHasRelationshipsWithFK_True_ShouldHaveThreeStep()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProp = MockRepository.GenerateMock<DMProperty>(ConstructForFakes.True);
            SetHasRelationshipWithFK(dmProp, true);
            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProp.HasRelationshipsWithRelatedFK);
            //---------------Execute Test ----------------------
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Test Result -----------------------
            Assert.AreEqual(3, cntrller.StepCount);
        }

        private static void SetHasRelationshipWithFK(DMProperty dmProp, bool hasRelationshipWithFK)
        {
            dmProp.Stub(@class => @class.HasRelationshipsWithRelatedFK).Return(hasRelationshipWithFK);
        }*/

/*
        

        [Test]
        public void Test_CompleteCurrentStep_WhenSecondStepCanMoveOn_ShouldCreateForeignKeyProps()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            TestUtilsShared.CreateSavedObjectIdentityInfo(dmProp);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            SetupStep1(cntrller);
            DMRelationshipCreator creator = cntrller.RelationshipCreator;
            Assert.IsFalse(cntrller.RelationshipCreator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsFalse(cntrller.RelationshipCreator.CanFindForeignKey);
            IWizardStep step = cntrller.GetNextStep();
            Assert.IsFalse(cntrller.RelationshipCreator.CanFindForeignKey);
            step.InitialiseStep();
            DMRelationship relationship = creator.Relationship;
            //---------------Assert Precondition----------------
            Assert.IsFalse(creator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep2), step);
            Assert.AreEqual(0, relationship.RelationshipProperties.Count);
            //---------------Execute Test ----------------------
            CreateRelationshipWizardStep2 step2 = (CreateRelationshipWizardStep2) step;
            step2.CardinalityComboBox.SelectedItem = Cardinality.Multiple.ToString();
            cntrller.CompleteCurrentStep();
            //---------------Test Result -----------------------
            Assert.IsNotNull(relationship);
            Assert.AreEqual(Cardinality.Multiple, relationship.Cardinality);
            Assert.AreEqual(StringUtilities.Pluralize(relationship.RelatedClass.ClassNameBO), relationship.RelationshipName);
            Assert.AreEqual(1, relationship.RelationshipProperties.Count);
        }

        [Test]
        public void Test_GetNextStep_WhenStep2_ShouldReturnStep3()
        {
            //---------------Set up test pack-------------------
            var container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            TestUtilsShared.CreateSavedObjectIdentityInfo(dmProp);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            SetupStep1(cntrller);
            IWizardStep step = cntrller.GetNextStep();
            step.InitialiseStep();
            CreateRelationshipWizardStep2 step2 = (CreateRelationshipWizardStep2)step;
            step2.CardinalityComboBox.SelectedItem = Cardinality.Multiple.ToString();
            string message;
            bool canMoveOn = cntrller.CanMoveOn(out message);
            //---------------Assert Precondition----------------
            Assert.IsTrue(canMoveOn);
            //---------------Execute Test ----------------------
            IWizardStep wizardStep = cntrller.GetNextStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), wizardStep);
        }

        [Test]
        public void Test_GetPreviousStep_WhenStep3_AndHadStep2_ShouldReturnStep2()
        {
            //---------------Set up test pack-------------------
            var container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            TestUtilsShared.CreateSavedObjectIdentityInfo(dmProp);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            SetupStep1(cntrller);
            IWizardStep step = cntrller.GetNextStep();
            step.InitialiseStep();
            CreateRelationshipWizardStep2 step2 = (CreateRelationshipWizardStep2)step;
            step2.CardinalityComboBox.SelectedItem = Cardinality.Multiple.ToString();
            string message;
            cntrller.CanMoveOn(out message);
            IWizardStep wizardStep = cntrller.GetNextStep();
            //---------------Assert Precondition----------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), wizardStep);
            //---------------Execute Test ----------------------
            IWizardStep previousStep = cntrller.GetPreviousStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep2), previousStep);
        }

        [Test]
        public void Test_CancelWizard_ShouldCallCreator_CancelAllEdits()
        {
            //---------------Set up test pack-------------------
            var container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            TestUtilsShared.CreateSavedObjectIdentityInfo(dmProp);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            SetupStep1(cntrller);
            IWizardStep step = cntrller.GetNextStep();
            step.InitialiseStep();
            CreateRelationshipWizardStep2 step2 = (CreateRelationshipWizardStep2)step;
            step2.CardinalityComboBox.SelectedItem = Cardinality.Multiple.ToString();
            string message;
            cntrller.CanMoveOn(out message);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(cntrller.RelationshipCreator.Relationship.OwnerClass);
            //---------------Execute Test ----------------------
            cntrller.CancelWizard();
            //---------------Test Result -----------------------
            Assert.IsNull(cntrller.RelationshipCreator.Relationship.OwnerClass);
            Assert.IsNull(cntrller.RelationshipCreator.Relationship.RelatedClass);
        }

        private static void SetupStep1(DeleteDMPropertyWizardController cntrller)
        {
            DMProperty relatedClass = TestUtilsDMProperty.CreateSavedDMProperty(cntrller.RelationshipCreator.Relationship.OwnerClass.Solution);
            TestUtilsShared.CreateSavedObjectIdentityInfo(relatedClass);
            CreateRelationshipWizardStep1 step1 = (CreateRelationshipWizardStep1) cntrller.GetFirstStep();
            step1.InitialiseStep();
            step1.RelatedClassComboBox.SelectedItem = relatedClass;
            string message;
            step1.CanMoveOn(out message);
            return;
        }

        #region if Not Owner Class and Related Class has Single Prop PrimaryKey

        [Test]
        public void Test_GetNextStep_WhenFirstStep_OwnerClassHasCompositePrimaryKey_ShouldReturnStep2()
        {
            //---------------Set up test pack-------------------
            var container = new UnityContainer();
            DMObjectIdentity identity = TestUtilsDMObjectIdentity.CreateUnsavedValidCompositeDMObjectIdentity();
            DMProperty dmProp = identity.Class;
            DMProperty relatedClass = TestUtilsDMProperty.CreateDMPropertyWithObjectIdentity(dmProp.Solution);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, dmProp.ObjectIdentity.Properties.Count);
            Assert.IsTrue(dmProp.IsObjectIDValid);
            Assert.IsTrue(relatedClass.IsObjectIDValid);

            //---------------Execute Test ----------------------
            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1) cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Test Result -----------------------
            string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);

            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetFirstStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep2), cntrller.GetNextStep());
        }

        [Test]
        public void Test_GetNextStep_WhenFirstStep_RelatedClassHasCompositePrimaryKey_ShouldReturnStep2()
        {
            //---------------Set up test pack-------------------
            DMObjectIdentity identity = TestUtilsDMObjectIdentity.CreateUnsavedValidCompositeDMObjectIdentity();
            DMProperty relatedClass = identity.Class;
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty(relatedClass.Solution);
            dmProp.ObjectIdentity = TestUtilsDMObjectIdentity.CreateUnsavedValidDMObjectIdentity_NoDMProperty();
            var container = new UnityContainer();
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, relatedClass.ObjectIdentity.Properties.Count);
            //---------------Execute Test ----------------------
            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1) cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Test Result -----------------------
            string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);

            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetFirstStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep2), cntrller.GetNextStep());
        }
        [Test]
        public void Test_GetNextStep_WhenFirstStep_OwnerClassNullObjectID_ShouldReturnStep2()
        {
            //---------------Set up test pack-------------------
            DMProperty relatedClass = TestUtilsDMProperty.CreateSavedDMProperty();
            var container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty(relatedClass.Solution);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Assert Precondition----------------
            Assert.IsNull(dmProp.ObjectIdentity);
            Assert.IsFalse(dmProp.IsObjectIDValid);
            //---------------Execute Test ----------------------
            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1) cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Test Result -----------------------
            string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);

            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetFirstStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep2), cntrller.GetNextStep());
        }

        [Test]
        public void Test_GetNextStep_WhenFirstStep_RelatedClassNullObjectID_ShouldReturnStep2()
        {
            //---------------Set up test pack-------------------
            DMProperty relatedClass = TestUtilsDMProperty.CreateSavedDMProperty();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty(relatedClass.Solution);
            dmProp.ObjectIdentity = TestUtilsDMObjectIdentity.CreateUnsavedValidDMObjectIdentity_NoDMProperty();
            var container = new UnityContainer();

            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dmProp.ObjectIdentity);
            Assert.IsNull(relatedClass.ObjectIdentity);
            //---------------Execute Test ----------------------
            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1) cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Test Result -----------------------
            string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);

            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep1), cntrller.GetFirstStep());
            Assert.IsInstanceOf(typeof (CreateRelationshipWizardStep2), cntrller.GetNextStep());
        }

        #endregion

        #region When Foreign Key Props Found

        //  Look for prop named OwnerClass + ID
        //  if found then
        //   - 1:M cardinality
        //   - RelattionshipName = Pluralise of RelatedClass
        //   - MyRelatedProp = IDProp
        //   - RelatedProp = foundProp
        //  The Remainder are Defaults
        //	== Create Reverse Relationship with names etc.
        //  	-- Show the user the std Relationship screen and allow them to edit anything.
        [Test]
        public void Test_GetNextStep_WhenFirstStep_RelatedClassHasForeignKey()
        {
            //---------------Set up test pack-------------------
            DMProperty ownerClass = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            TestUtilsShared.CreateSavedObjectIdentityInfo(ownerClass);
            DMProperty relatedClass = TestUtilsDMProperty.CreateSavedDMProperty(ownerClass.Solution);
            TestUtilsShared.CreateSavedObjectIdentityInfo(relatedClass);
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(relatedClass);
            property.PropertyName = ownerClass.ClassNameBO + "ID";
            var container = new UnityContainer();

            var cntrller = new CreateRelationshipWizardController(container, ownerClass);

            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1)cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(ownerClass.ObjectIdentity);
            Assert.IsNotNull(relatedClass.ObjectIdentity);
            Assert.IsNotNull(relatedClass.GetDMProperty(property.PropertyName)); string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetFirstStep());
            //---------------Execute Test ----------------------
            IWizardStep actual = cntrller.GetNextStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), actual);
        }
        //   - If Related Class has single Prop ID
        //     Look for Prop in OwnerClass = RelatedClass + ID
        //     If found 
        //	- M:1 cardinality
        //   	- RelattionshipName = Singularise of RelatedClass
        //   	- MyRelatedProp = foundProp
        //   	- RelatedProp = RelatedProp.IDProp
        // 	Remainder Default
        [Test]
        public void Test_GetNextStep_WhenFirstStep_OwnerClassHasForeignKey()
        {
            //---------------Set up test pack-------------------
            DMProperty ownerClass = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            TestUtilsShared.CreateSavedObjectIdentityInfo(ownerClass);
            DMProperty relatedClass = TestUtilsDMProperty.CreateSavedDMProperty(ownerClass.Solution);
            TestUtilsShared.CreateSavedObjectIdentityInfo(relatedClass);
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(ownerClass);
            property.PropertyName = relatedClass.ClassNameBO + "ID";
            var container = new UnityContainer();

            var cntrller = new CreateRelationshipWizardController(container, ownerClass);

            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1)cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(ownerClass.ObjectIdentity);
            Assert.IsNotNull(relatedClass.ObjectIdentity);
            Assert.IsNotNull(ownerClass.GetDMProperty(property.PropertyName)); string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetFirstStep());
            //---------------Execute Test ----------------------
            IWizardStep actual = cntrller.GetNextStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), actual);
        }
        [Test]
        public void Test_GetPreviousStep_WhenStep3_DidNotHaveStep2_ShouldReturnStep1()
        {
            //---------------Set up test pack-------------------
            IUnityContainer container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            var relationshipCreator = MockRepository.GenerateMock<DMRelationshipCreator>(dmProp);
            container.RegisterInstance(relationshipCreator);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            relationshipCreator.Stub(creator => creator.CanFindForeignKey).Return(true);
            cntrller.GetFirstStep();
            var step3 = cntrller.GetNextStep();
            //---------------Assert Precondition----------------
            Assert.IsTrue(relationshipCreator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), step3);
            //---------------Execute Test ----------------------
            IWizardStep previousStep = cntrller.GetPreviousStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), previousStep);
        }

        [Test]
        public void Test_GetNextStep_WhenStep1_PreviouslyReturnedFromStep3_ShouldReturnStep3()
        {
            //---------------Set up test pack-------------------
            IUnityContainer container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            var relationshipCreator = MockRepository.GenerateMock<DMRelationshipCreator>(dmProp);
            container.RegisterInstance(relationshipCreator);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            relationshipCreator.Stub(creator => creator.CanFindForeignKey).Return(true);
            cntrller.GetFirstStep();
            var step3 = cntrller.GetNextStep();
            //---------------Intermediate Asserts---------------
            Assert.IsTrue(relationshipCreator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), step3);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), cntrller.GetCurrentStep());
            //--------------Move Back---------------------------
            var previousStep = cntrller.GetPreviousStep();
            //---------------Assert Precondition---------------
            Assert.IsTrue(relationshipCreator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), previousStep);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            //---------------Execute Test ----------------------
            var finalStep = cntrller.GetNextStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), finalStep);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), cntrller.GetCurrentStep());
        }

        [Test]
        public void Test_GetNextStep_WhenStep1_PreviouslyReturnedFromStep3_WhenChangedChoiceAndNow_ShouldReturnStep2()
        {
            //---------------Set up test pack-------------------
            IUnityContainer container = new UnityContainer();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty();
            var relationshipCreator = MockRepository.GenerateMock<DMRelationshipCreator>(dmProp);
            container.RegisterInstance(relationshipCreator);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            relationshipCreator.Stub(creator => creator.CanFindForeignKey).Return(true);
            cntrller.GetFirstStep();
            var step3 = cntrller.GetNextStep();
            //---------------Intermediate Asserts---------------
            Assert.IsTrue(relationshipCreator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), step3);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), cntrller.GetCurrentStep());
            //--------------Move Back---------------------------
            var previousStep = cntrller.GetPreviousStep();
            //---------------Assert Precondition---------------
            Assert.IsTrue(relationshipCreator.CanFindForeignKey);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), previousStep);
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            //---------------Execute Test ----------------------
            relationshipCreator.ClearStubReturnValues();
            relationshipCreator.Stub(creator => creator.CanFindForeignKey).Return(false);
            Assert.IsFalse(relationshipCreator.CanFindForeignKey);
            IWizardStep nextStep = cntrller.GetNextStep();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep2), nextStep);
        }

        [Test]
        public void Test_GetNextStep_WhenFirstStep_WhenIsRelationshipSetup_ShouldReturnStep3()
        {
            //---------------Set up test pack-------------------
            DMProperty relatedClass = TestUtilsDMProperty.CreateSavedDMProperty();
            DMProperty dmProp = TestUtilsDMProperty.CreateSavedDMProperty(relatedClass.Solution);
            var container = new UnityContainer();
            var mockCreator = MockRepository.GenerateMock<DMRelationshipCreator>(dmProp);
            mockCreator.Stub(creator => creator.CanFindForeignKey).Return(true);
            container.RegisterInstance(mockCreator);
            var cntrller = GetDeleteDMPropertyWizardController(dmProp);
            //---------------Assert Precondition----------------
            Assert.IsTrue(mockCreator.CanFindForeignKey);
            //---------------Execute Test ----------------------
            CreateRelationshipWizardStep1 step = (CreateRelationshipWizardStep1)cntrller.GetNextStep();
            step.InitialiseStep();
            step.RelatedClassComboBox.SelectedItem = relatedClass;
            //---------------Test Result -----------------------
            string message;
            Assert.IsTrue(step.CanMoveOn(out message), message);

            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep1), cntrller.GetCurrentStep());
            Assert.IsInstanceOf(typeof(CreateRelationshipWizardStep3), cntrller.GetNextStep());
        }
        #endregion*/
    }
}